package com.info.zhiduoduo.admin.controller;

import com.info.zhiduoduo.admin.model.formbean.customer.QueryFollowingFormBean;
import com.info.zhiduoduo.admin.model.formbean.customer.SaveFollowingFormBean;
import com.info.zhiduoduo.admin.model.formbean.customer.UpdateFollowingFormBean;
import com.info.zhiduoduo.admin.service.FollowingService;
import com.info.zhiduoduo.common.annotation.LogEntity;
import com.info.zhiduoduo.common.annotation.LogParameter;
import com.info.zhiduoduo.common.annotation.ZddLog;
import com.info.zhiduoduo.common.constants.SmartResult;
import com.info.zhiduoduo.common.constants.system.ZddLogType;
import com.info.zhiduoduo.common.formbean.BaseSimpleFormBean;
import com.info.zhiduoduo.repository.entity.customer.Following;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "客服事务异常跟进记录")
@RestController
@RequestMapping("/following")
public class FollowingController {
    @Autowired
    FollowingService followingService;

    @ZddLog(name = "增加客服异常跟进记录")
    @ApiOperation("增加客服异常跟进记录")
    @PostMapping("/saveFollowing")
    public SmartResult saveFollowing(@RequestBody BaseSimpleFormBean<SaveFollowingFormBean> formBean) {
        return followingService.saveFollowing(formBean);
    }

    @ApiOperation("查询客服异常跟进记录")
    @PostMapping("/findFollowingByServiceErrorId")
    public SmartResult findFollowingByRelationId(@RequestBody BaseSimpleFormBean<QueryFollowingFormBean> formBean) {
        return followingService.findFollowingByRelationId(formBean);
    }

    @ZddLog(type = ZddLogType.UPDATE,name = "修改客服异常跟进记录",entities = @LogEntity(entity = Following.class,parameters =
    @LogParameter(fields = "id",parameters = "formBean.reqdata.id")))
    @ApiOperation("修改客服异常跟进记录")
    @PostMapping("/updateFollowing")
    public SmartResult updateFollowing(@RequestBody BaseSimpleFormBean<UpdateFollowingFormBean> formBean){
        return followingService.updateFollowing(formBean);
    }


}
